<!DOCTYPE html>
<!--
Collabsoft-12 class
Engine by Abdelrahman Hazem (Ronin)
Extensive testing by Debugger Atef Sami (Aderaim)
-->
<html>
    <?php
    if (isset($_POST['register']))
    {
        header("Location: Register.php");
    }
    else if (isset($_POST['login']))
    {
        include 'ClassLibs/statics.php';
        $sUser = $_POST['userfield'];
        $sPass = $_POST['passfield'];
        if (bLogin($sUser, $sPass))
        {
            session_start();
            $_SESSION['userid'] = $sUser;
            $_SESSION['prev_posts'] = null;
            header("Location: BlogMain.php");
        }
        else
        {
            echo"Log in unsuccessful";
        }
    }
    ?>
    <head>
        <link rel="stylesheet" type="text/css" href="index_style.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form method="POST" id="login_form">
            <table>
                <tr>
                    <td>Username:</td>
                    <td><input type="text" name="userfield" maxlength="50"/></td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="passfield" maxlength="50"/><br/></td>
                </tr>
                <tr>
                    <td><input type="submit" name="login" value="Log in"/></td>
                    <td><input type="submit" name="register" value="Register"/></td>
                </tr>
            </table>
        </form>
    </body>        
    
</html>
